<?
if (!defined('MODULE_FILE')){
	die ("cant access file directly!");
}

$mid 	= ( ( true == isset( $_GET['mid'] ) && true == valStr( $_GET['mid'] ) ) ? $_GET['mid'] : NULL );
$smid 	= ( ( true == isset( $_GET['smid'] ) && true == valStr( $_GET['smid'] ) ) ? $_GET['smid'] : NULL );

autoLoader();

$objBaseEmployeeTypes 	= new BaseEmployeeTypes();
$objEmployeeTypes 	= new EmployeeTypes();
?>
<html>
<head>
<?php require_once 'commonJS.php'; ?>
</head>
<body>
<div style="margin-left:12px; margin-top: 10px;">
	<p>
		<a class="btn btn-outline btn-primary btn-xs" id="act" href="modules.php?file=employee_types&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Add New Employees Type</a>
		<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=view_employee_types&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >View All Employee Type</a>&nbsp;
	</p>
</div>

<div class="col-lg-8">
<div class="panel panel-primary">
<div class="panel-heading"><i class="fa fa-bell fa-fw"></i> Employee Types</div>
<div class="panel-body">

<form METHOD="POST" action="modules.php?file=insert_employee_types&type=insert&mid=<? echo $mid; ?>&smid=<? echo $smid; ?>" id="formSubmit" name="formSubmit" >
		<?php
		$intEmpTypeId = NULL;
		$strName 			= NULL;
		$strDescription 	= NULL;
		$boolIsPublished 	= true;
				
		if( true == isset( $_GET['emp_type_id'] ) && true == valStr( $_GET['emp_type_id'] ) ) {
			$intEmpTypeId = $_GET['emp_type_id'];
			
			$objBaseEmployeeTypes = $objEmployeeTypes->fetchEmployeeTypesById( $_GET['emp_type_id'] );
			
			if( true == valObj( $objBaseEmployeeTypes, 'BaseEmployeeTypes' ) ) {
				$strName 				= $objBaseEmployeeTypes->getName();
				$strDescription 		= $objBaseEmployeeTypes->getDescription();
				$boolIsPublished 		= $objBaseEmployeeTypes->getIsPublished();
			}
		} else if( true == valObj( $objBaseEmployeeTypes, 'BaseEmployeeTypes' ) ) {
			$intEmpTypeId = $objBaseEmployeeTypes->fetchNextId();
		}
		?> 
		<table width="80%" cellspacing="0" cellpadding="3">
		<tr><td height="10" colspan="2"><input id="emp_type_id" Name="emp_type_id" type="hidden"  style="width:100px;"  value="<?php echo $intEmpTypeId;?>"></td></tr>
          
			<tr valign="top">
				<td  width="220">Name</td>
				<td><input id="name" Name="name" type="text" class="validate[required]" value="<?php echo $strName;?>" style="width:202px;"></td>
			</tr>
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			  <tr valign="top">
				<td  width="220">Description</td>
				<td><textarea name="description" rows="5" cols="40"><?php echo $strDescription;?></textarea></td>
			</tr>
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			<tr valign="top">
				<td  width="220">Is Published</td>
				<td><input id="is_published" Name="is_published" type="text" class="validate[required]" value="<?php echo $boolIsPublished;?>" style="width:202px;"></td>
			</tr>
			
			<tr>
				<td colspan="2" height="10px"></td>
			</tr>
			<tr valign="top">
				<td class="mandatory" width="220">&nbsp;</td>
				<td>
				<?php
					if( true == isset( $_GET['emp_type_id'] ) && true == valStr( $_GET['emp_type_id'] ) ) {
						echo "<input type=hidden name=operation value=update>";
						echo "<input type=submit value=UPDATE id=Submit name=Submit>";
					} else {
						echo "<input type=hidden name=operation value=insert>";
						echo "<input type=submit value=SUBMIT id=Submit name=Submit>";
					}
					?>
				
				</td> 				
			</tr>
		</table>
</div>
</div>
</div>	
</form>
</body>
</html>